﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChronoScript_Compiler.Language.Parser
{
    public partial class Parser
    {
        public LanguageDefinition.FunctionCall Call()
        {
            LanguageDefinition.FunctionCall funcCall = new LanguageDefinition.FunctionCall();
            funcCall.Target = ReadToken().ToString();
            if (!(ReadToken() is Tokens.openParenthesis)) Console.WriteLine("Expected (");
            while (!(PeekToken() is Tokens.closeParenthesis))
            {
                funcCall.Arguments.Add(ParseExpression());
                if (PeekToken() is Tokens.Comma)
                {
                    ReadToken();
                    if (PeekToken() is Tokens.closeParenthesis)
                        Console.WriteLine("Unexpected ,");
                }
            }
            ReadToken();
            return funcCall;
        }

    }
}
